{% extends "layout.html" %}

{% block title %}脚本区{% endblock %}

{% block css %}{% endblock %}

{% block cardbody %}

<div class="layui-form">
    

    <div class="layui-form-item">
        <div class="layui-input-group">
            <div class="layui-input-split layui-input-prefix">
                若开启即关注，则表示启动为目标提供粉丝服务；若未开启，则为目标账号筛选出我们的僵尸成员，并提供取消关注服务。
            </div>
            <div class="layui-input-suffix">
                <input type="checkbox" name="CCC" title="开启|关闭" checked id="isCheck" lay-skin="switch" >
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-group">
            <div class="layui-input-split layui-input-prefix">
                被关注者ID
            </div>
            <input type="text" placeholder="请输入目标ID" class="layui-input">
            <div class="layui-input-suffix">
                <button id="Start" class="layui-btn layui-btn-primary" lay-submit lay-filter="demo-submit">开始批量关注</button>
            </div>
        </div>
    </div>

</div>
{% endblock %}

{% block js %}
<!-- 171316155701 -->
<script>
    var layer = layui.layer
    document.querySelector("#Start").addEventListener('click', () => {
        let isCheck = document.querySelector("#isCheck").checked;
        let PostsID = document.querySelector('.layui-input').value;
        if (PostsID == "") {return layer.msg("请输入目标id")}
        let isss = ""
        if (isCheck) {
             isss = "op"
        }
        var loadIndex = layer.msg('加载中', {
        icon: 16,
        shade: 0.5,
        title: "稍等一会...",
        content: "正在批量关注中...",
        anim: 6,
        time:0

      });;
        
        // 向服务器发送
        axios({
            url: "/GuanZhu/",
            method: "POST",
            headers: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            data: {
                "id": PostsID,
                "isG": isss
            }
        }).then(res => {
            console.log("响应成功: ", res);
            layer.msg(`脚本运行完毕, 成功启动了  ${res.data.umber}  个僵尸关注目标账号!`)
            layer.close(loadIndex);
        }).catch(error => {
            console.error("响应失败: ", error);
            layer.close(loadIndex);
        });

    })
   
</script>

{% endblock %}